package com.sky.utils;

import org.apache.commons.lang3.RandomUtils;

/**
 * 随机验证码生成工具类
 */
public class RandomCode {

    /**
     * 生成4位随机数字验证码
     * @return 4位随机数字组成的字符串
     */
    public static String  getRandomCode(){
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            int anInt = RandomUtils.nextInt(0, 9);
            stringBuilder.append(anInt);
        }
        return stringBuilder.toString();
    }
}
